<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Contoh extends CI_Controller
{
    public function index()
    {
        $this->load->library('cafebz');
        
        $time = mktime(0,0,0,4,9,2012);
        
        $data['revenue'] = $this->cafebz->sf_revenue_daily($time);
        $data['media_collection'] = $this->cafebz->sf_media_collection_daily($time);
        $data['department'] = $this->cafebz->sf_department_daily($time);
        $data['sales'] = $this->cafebz->sf_sales_daily($time);
        
        $this->load->view('contoh',$data);
    }
    
    public function generate_report()
    {
        $data = array();
        
        $this->load->library('cafebz');
        $post = $this->input->post();
        $query = null;
        if($post)
        {
            if($post['type']=='s')
            {
                $query = $this->cafebz->sf_sales_monthly((int)$post['month'],(int)$post['year']);
                $data['sales'] = $query;
            }
            else if($post['type']=='p')
            {
                $query = $this->cafebz->sf_payment_monthly((int)$post['month'],(int)$post['year']);
                $data['payment'] = $query;
            }
        }
        
        $headers = array("Day","Date","Beverage","Food","Tobaco","Others","Discount","Rounding","Net Sales","Tax","Service","Subtotal","Month to Date");
        
        $this->load->library('excelout');
        $this->excelout->to_excel($query,$headers,'Contoh_Excel');
        
        $this->load->view('contoh-monthly',$data);
    }
    
    public function velpa_sales_test()
    {
        $this->load->library('cafebz');
        
        $bulan = 4;
        $tahun = 2012;
        $query = $this->cafebz->velpa_sales_monthly($bulan,$tahun);
        $data['bulan'] = $bulan;
        $data['tahun'] = $tahun;
        $data['sales'] = $query;
        
        $data['nama_akun'] = 'test velpa';
        $data['main_content'] = 'penjualan';   
        $data['table'] = $this->load->view('monthly_report_velpa',$data,TRUE);
        $this->load->view('include/template',$data);
    }
    
    public function velpa_payment_test()
    {
        $this->load->library('cafebz');
        
        $bulan = 4;
        $tahun = 2012;
        $query = $this->cafebz->velpa_payment_monthly($bulan,$tahun);
        $data['bulan'] = $bulan;
        $data['tahun'] = $tahun;
        $data['payment'] = $query;
        
        $data['nama_akun'] = 'test velpa';
        $data['main_content'] = 'penjualan';   
        $data['table'] = $this->load->view('monthly_report_velpa',$data,TRUE);
        $this->load->view('include/template',$data);
    }
    
    public function sf_sales_test()
    {
        $this->load->library('cafebz');
        
        $bulan = 12;
        $tahun = 2011;
        $query = $this->cafebz->sf_sales_monthly($bulan,$tahun);
        $data['bulan'] = $bulan;
        $data['tahun'] = $tahun;
        $data['sales'] = $query;
        
        $data['nama_akun'] = 'test sf';
        $data['main_content'] = 'penjualan';   
        //$data['table'] = $this->load->view('monthly_report_sf',$data,TRUE);
        $this->load->view('monthly_report_sf',$data,TRUE);
    }
    
    public function sf_payment_test()
    {
        $this->load->library('cafebz');
        
        $bulan = 3;
        $tahun = 2012;
        $query = $this->cafebz->sf_payment_monthly($bulan,$tahun);
        $data['bulan'] = $bulan;
        $data['tahun'] = $tahun;
        $data['payment'] = $query;
        
        $data['nama_akun'] = 'test velpa';
        $data['main_content'] = 'penjualan';   
        $data['table'] = $this->load->view('monthly_report_sf',$data,TRUE);
        $this->load->view('include/template',$data);
    }
    
    public function cox_sales_test()
    {
        $this->load->library('cafebz');
        
        $bulan = 4;
        $tahun = 2012;
        $query = $this->cafebz->cox_sales_monthly($bulan,$tahun);
        $data['bulan'] = $bulan;
        $data['tahun'] = $tahun;
        $data['sales'] = $query;
        
        $data['nama_akun'] = 'test cox';
        $data['main_content'] = 'penjualan';   
        $data['table'] = $this->load->view('monthly_report_cox',$data,TRUE);
        $this->load->view('include/template',$data);
    }
    
    public function cox_payment_test()
    {
        $this->load->library('cafebz');
        
        $bulan = 4;
        $tahun = 2012;
        $query = $this->cafebz->cox_payment_monthly($bulan,$tahun);
        $data['bulan'] = $bulan;
        $data['tahun'] = $tahun;
        $data['payment'] = $query;
        
        $data['nama_akun'] = 'test cox';
        $data['main_content'] = 'penjualan';   
        $data['table'] = $this->load->view('monthly_report_cox',$data,TRUE);
        $this->load->view('include/template',$data);
    }
    
    public function test()
    {
        $this->load->model('cafebz_model');
        $data = array('subtotal'=>0);
        $this->cafebz_model->insert_cox_sales($data);
    }

}

?>
